#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<algorithm>
#include<string.h>
int main()
{
	char a[10000];
	gets(a);
	int k = 0;
	scanf("%d", &k);
	reverse(a, (char*)(strlen(a) - 1));
	reverse(a, a + k - 1);
	reverse(a + k - 1, strlen(a) - 1);
	for (int i = 0; i < strlen(a) - 1; i++)
		printf("%c", a[i]);
	return 0;
}

//char temp = a[left];
//a[left] = a[right];
//a[right] = temp;